﻿//jQuery.noConflict();

jQuery.extend({
    getQueryString: function(queryName) {
        var queryValue = "";
        var queryFound = false;
        if (window.location.search != "") {
            var search = window.location.search;
            var i = 0;
            while (i <= search.length) {
                start = i;
                end = start + queryName.length;
                if (search.substring(start, end) == queryName) {
                    queryFound = true;
                    break;
                }
                i++;
            }
            if (queryFound) {
                start = end + 1;
                end = search.indexOf("&", start);
                if (end < start)
                    end = search.length;
                var getvalue = search.substring(start, end);
                return unescape(getvalue);
            }
        }
        return queryValue;
    },
    refresh: function(filter) {  
        filter=( filter !=null && filter !="")?("&"+filter ):"";                 
        var urldd = window.location.toString();

        var hashIndex = urldd.indexOf("#");
        if (hashIndex >= 0) {
            urldd = urldd.substr(0, hashIndex);   
        }
        var version = jQuery.getQueryString("v_t");
        var versiionValue = Math.round(Math.random() * 100000);
        if (version == "") {
            if (window.location.search != "") {
                window.location = urldd + "&v_t=" + versiionValue + filter ;
            }
            else {
                window.location = urldd + "?v_t=" + versiionValue + filter;
            }
        }
        else {
            var oldVersionStr = "v_t=" + version;
            var newVersionStr = "v_t=" + versiionValue;
            window.location = urldd.replace(oldVersionStr, newVersionStr)+filter ;
        }
    },
    close: function() {
        window.opener = null;
        window.open("", "_self");
        window.close();
    }
});  